package com.cn.redis.serialize;

import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.util.Assert;

/**
 * @author Han
 */
public class StringSerializerExtend extends StringRedisSerializer{
	private String key;
	public StringSerializerExtend(String key){
		super();
		Assert.notNull(key);
		this.key = key;
	}
	
	public String deserialize(byte[] bytes) {
		String tmp = super.deserialize(bytes);
		return tmp.substring(key.length(),tmp.length());
	}

	
	public byte[] serialize(String string) {
		String tmp = key+string;
		return super.serialize(tmp);
	}
}
